package br.com.ss.entity;


import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
 
@Entity
@Table(name = "USERS")
@NamedQuery(name="User.findUserByEmail", query="select u from User u where u.email = :email")

public class User extends AbstractEntity implements Serializable{

	private static final long serialVersionUID = 4893707006245955551L;


	public static final String FIND_BY_EMAIL = "User.findUserByEmail";

	//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="id")
    private Long id;
	
	@Column(name="idusuariocriacao")
	private Long idUsuarioCriacao;

	@Column(name="idusuarioalteracao")
	private Long idUsuarioAlteracao;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="dataCriacao")
	private Date dataCriacao;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="dataAlteracao")
	private Date dataAlteracao;

	
	//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-
	
	@Column(unique = true, name = "email")
    private String email;
   
	@Column(name="password")
    private String password;
    
	@Column(name="name")
    private String name;
    
	@Column(name="role")
    private String role;
    
  //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-==-
 
   	public Date getDataCriacao() {
		return dataCriacao;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getIdUsuarioCriacao() {
		return idUsuarioCriacao;
	}

	public void setIdUsuarioCriacao(Long idUsuarioCriacao) {
		this.idUsuarioCriacao = idUsuarioCriacao;
	}

	public Long getIdUsuarioAlteracao() {
		return idUsuarioAlteracao;
	}

	public void setIdUsuarioAlteracao(Long idUsuarioAlteracao) {
		this.idUsuarioAlteracao = idUsuarioAlteracao;
	}

	public void setDataCriacao(Date dataCriacao) {
		this.dataCriacao = dataCriacao;
	}

	
	public Date getDataAlteracao() {
		return dataAlteracao;
	}

	public void setDataAlteracao(Date dataAlteracao) {
		this.dataAlteracao = dataAlteracao;
	}
    
    public String getEmail() {
        return email;
    }
 
    public void setEmail(String email) {
        this.email = email;
    }
 
    public String getPassword() {
        return password;
    }
 
    public void setPassword(String password) {
        this.password = password;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getRole() {
        return role;
    }
 
    public void setRole(String role) {
        this.role = role;
    }
    
   
    @Override
	public String toString() {
		
		StringBuilder sb = new StringBuilder();
		
		sb.append(" [ ");
		sb.append(" User ");
		sb.append(" id = ").append(getId());
		sb.append(" nome = ").append(getName());
		sb.append(" email ").append(getEmail());
		sb.append(" regra ").append(getRole());
		sb.append(" ] ");
		
		return sb.toString();
	}
	
}
